﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Swd05.SH.Bll;
using Swd05.SH.Dal;
using Swd05.SH.Interfaces;

namespace Swd05.SH
{
	public class Facade
	{
		private static readonly Facade instance = new Facade();
		
		private Facade()
		{
		}
		#region Properties
		public static Facade Instance
		{
			get
			{
				return Facade.instance;
			}
		}
		#endregion
		#region Methods
		public IScriptFactory Create( Source source, string configuration )
		{
			IScriptFactory factory = null;
			switch (source)
			{
				case Source.Sql:
					factory = new SqlScriptFactory();
					break;
				case Source.File:
					factory = new FileScriptFactory();
					break;
				case Source.Ram:
					factory = new RamScriptFactory();
					break;
				default:
					throw new ArgumentException( string.Format( "Keine Datenquelle für ID='{0}' verfügbar!", Enum.GetName( typeof( Source ), source ) ) );
			}
			factory.Connect( configuration );
			return factory;
			
		}
		#endregion
	}
}
